package eight_shangchuan;

import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;
import java.util.Arrays;

public class Client {
    public static void main(String[] args) {
        try (
                InputStream is = new FileInputStream("mian\\src\\eight_shangchuan\\from.jpg");
                ) {
            Socket s = new Socket("127.0.0.1", 8888);
            DataOutputStream dos = new DataOutputStream(s.getOutputStream());
            dos.writeUTF(".jpg");

            byte[] bys = new byte[1024];
            int len;
            while ((len = is.read(bys)) != -1) {
                dos.write(bys, 0, len);
//                System.out.println(Arrays.toString(bys));
            }
            dos.flush();
            s.shutdownOutput();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
